import { constantRouterMap } from '@/router'

const permission = {
    state: {
        routers: constantRouterMap,
        addRouters: []
    },
    getters: {
        permission_routers: state => state.routers,
        addRouters: state => state.addRouters
    },
    mutations: {
        SET_ROUTERS: (state, routers) => {
            state.addRouters = routers
            state.routers = constantRouterMap.concat(routers) // 总路由
        }
    },
    actions: {
        GenerateRoutes({commit}) {
            return new Promise(resolve => {
                let accessedRouters = '';
                accessedRouters = asyncRouterMap
                commit('SET_ROUTERS', accessedRouters)
                resolve()
            })
        }
    }
}

export default permission